package com.zh.article;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @description:
 * @author: zhangHang
 * @date: Created in 2020/5/23 15:12
 * @version: 1.0
 * @modified By:
 */
public class WeaponSet {
    private ArrayList<Weapon> weapons = new ArrayList<>();
    private String id;
    private String description;
    public WeaponSet() {
    }

    public WeaponSet(String id, String description) {
        this.id = id;
        this.description = description;
    }

    public WeaponSet(ArrayList<Weapon> weapons) {
        this.weapons = weapons;
    }

    public Weapon get(String id){
        Weapon weapon = null;
        for (Weapon item: weapons
             ) {
            if(id.equals(item.getId())){
                weapon = item;
                break;
            }
        }
        return weapon;
    }

    public void remove(String id){
        Iterator<Weapon> it = weapons.iterator();
        while (it.hasNext()){
            Weapon value = it.next();
            if(value.equals(get(id))){
                it.remove();
            }
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public ArrayList<Weapon> getWeapons() {
        return weapons;
    }

    public void setWeapons(ArrayList<Weapon> weapons) {
        this.weapons = weapons;
    }

}
